import {Pipe, PipeTransform} from '@angular/core';
import {UserService} from '@kylin/user';

@Pipe({
    name: 'translateText'
})
export class TranslateTextPipe implements PipeTransform {

    target = ['task-submit', 'information-submis'];

    constructor(private userService: UserService) {

    }

    transform(value: any, args?: any): any {
        const roleName = this.userService.getValue('roleName');
        if (this.target.indexOf(value) !== -1) {
            let result = '';
            switch (value) {
                case 'task-submit':
                    roleName === 'areaAdmin' ? result = '任务申请' : result = '任务审核';
                    break;
                case 'information-submis':
                    roleName === 'areaAdmin' ? result = '信息报送' : result = '信息审核';
                    break;
            }
            return result;
        } else {
            return value;
        }

    }

}
